<?php
header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Content-type: text/xml");
$time_1 = microtime();
require("../config.php");
include_once("functii.php");

#begin verificare 
echo '<?xml version="1.0" ?><arbore>';
 
//verificare mesaje sistem / mesaje admin/ mesaje personale
$query = mysql_query("SELECT * FROM mesaje WHERE dest = '".$user."' AND status = 'necitit' AND dest_stg = 'nesters' ORDER BY timp ASC");
while($rez = mysql_fetch_array($query))
{
$id = $rez["id"];
$expeditor = $rez["exp"];
if (strtoupper($expeditor) == strtoupper("sistem"))
$tip = "mesaj_sistem";
 else
$tip = "mesaj_privat";
$valoare = $rez["subiect"];
$timp = explode(" ", $rez["timp"]);

echo '<notificare><id>'.$id.'</id><tip>'.$tip.'</tip><expeditor>'.$expeditor.'</expeditor><valoare>'.$valoare.'</valoare><timp>'.$timp[1].'</timp></notificare>';
}

//verificare atacuri / intariri / resurse
$query2 = mysql_query("SELECT * FROM actiuni_globale WHERE dest_planeta = '".$planeta."' OR exp_planeta = '".$planeta."' ORDER BY durata DESC");
while($rez = mysql_fetch_array($query2))
{
$id = $rez["id"];
$planeta_exp = $rez["exp_planeta"]; 
$planeta_dest = $rez["dest_planeta"];
$expeditor = valoare_mysql("SELECT user FROM planete WHERE id = '".$planeta_exp."'");
$destinatar = valoare_mysql("SELECT user FROM planete WHERE id = '".$planeta_dest."'");
$tip = $rez["tip"];
$valoare = $rez["valoare"];
$incepere = $rez["incepere"];
$durata = $rez["durata"];
$date_sum = verificare_data($incepere, $durata, "term");
$timp= calculare_sec(time(), $date_sum, "sec");
 
 if ($tip == "intoarcere" && $planeta_dest == $planeta) {
 $tip = "intoarcere";
 } elseif ($tip == "intoarcere" && $planeta_exp == $planeta)
 $tip = "";
 
 if ($tip == "atac" && $expeditor == $user)
  $tip = "atac_trimis"; 
 elseif ($tip == "atac" && $destinatar == $user)
  $tip = "atac_primit";
  
if ($tip != "") 
echo '<notificare>
       <id>'.$id.'</id>
	   <tip>'.$tip.'</tip>
	   <expeditor>'.$expeditor.'</expeditor>
	   <valoare>'.$valoare.'</valoare>
	   <timp>'.$timp.'</timp>
	  </notificare>';
}

$time_2 = microtime()-$time_1;
echo '<notificare><id>0</id><tip>0</tip><expeditor>0</expeditor><valoare>0</valoare><timp>'.$time_2.'</timp></notificare>';

echo '</arbore>';
#end verificare

mysql_close($db);

?>

